﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace Domain
{
    /// <summary>
    /// Заезд
    /// </summary>
    public class Run: INotifyPropertyChanged
    {
        #region Fields
        
        private String _name;

        #endregion

        #region Properties
        
        /// <summary>
        /// Название
        /// </summary>
        public String Name
        {
            get { return _name; }
            set
            {
                bool changed = value != _name;
                _name = value;
                if (changed) InvokePropertyChanged(new PropertyChangedEventArgs("Name"));
            }
        } 

        /// <summary>
        /// Список категорий, которые участвуют в данном заезде
        /// </summary>
        public ObservableCollection<Category> Categories { get; private set; }

        #endregion

        /// <summary>
        /// Создаёт класс Run
        /// </summary>
        /// <param name="name">Название заезда</param>
        public Run(String name)
        {
            Name = name;
            Categories = new ObservableCollection<Category>();
        }

        #region Implementation of INotifyPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;

        public void InvokePropertyChanged(PropertyChangedEventArgs e)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, e);
        }

        #endregion
    }
}
